import { UrlService } from './../../../providers/url-service';
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { WalletZhanDoumxPage } from './wallet-zhandoumx/wallet-zhandoumx';
import { WalletYuemxPage } from './wallet-yuemx/wallet-yuemx';
import { WalletYaoQingMxPage } from './wallet-yaoqingmx/wallet-yaoqingmx';

@Component({
  selector: 'page-user-mywallet',
  templateUrl: 'user-mywallet.html',
})
export class UserMywalletPage {
  mywalletData;
  constructor(public navCtrl: NavController,
    public navParams: NavParams,
    public url: UrlService
  ) {
    this.mywalletData = {
      RMB: 0.00,
      Currency: "",
      Integral: ""
    }
    this.init();
  }

  init() {
    this.getUserInfo();
  }

  getUserInfo() {

    this.url.getUser("")
      .then(data => {
        if (data.Code == 0) {
          let obj = data.Data;
          this.mywalletData = {
            RMB: obj.RMB,
            Currency: obj.Currency,
            Integral: obj.Integral
          }

          //console.log(this.mywalletData);
        }
      })
      .catch()


  }

  /**
   * 
   * goPage
   */

  public goPage(pageName) {
    //console.log(pageName);
    switch (pageName) {
      case "yuemx":
        this.navCtrl.push(WalletYuemxPage);
        break;
      case "zhandoumx":
        this.navCtrl.push(WalletZhanDoumxPage);
        break;
      case "yaoqingmx":
        this.navCtrl.push(WalletYaoQingMxPage);
        break;
    }
  }


}

